using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text;
using System.Data; 
using yq.IBase; 
using yq.Dictionary; 
using yq.Basis; 
using yq.Model.Logic;
using System.Collections; 
using Db; 
using System.Data.Common;

namespace yq.Model.Base 
{
    ///<summary>
    /// User_Info - 用户详细 - 对象基础类
    /// </summary>
    ///<typeparam name="T"></typeparam>
    public abstract class IUserInfo<T> :ModelBase<UserInfo> where T : UserInfo, new()
    {
        /// <summary>
        /// 写入主键值
        /// </summary>
        /// <param name="Id">主键</param>
        protected internal override void SetKeyValue(dynamic Id)
        {
            this.UserId = Id;
        }

        /// <summary>
        /// 获取主键值
        /// </summary>
        /// <returns></returns>
        protected internal override dynamic GetKeyValue()
        {
            return UserId;
        }

        /// <summary>
        /// 为本对象赋值
        /// </summary>
        /// <param name="dy"></param>
        public override void SetValue(dynamic dy) 
        {
           this.UserId=dy.UserId;
           this.DepartmentId=dy.DepartmentId;
           this.Name=dy.Name;
           this.Email=dy.Email;
           this.HeadFlieId=dy.HeadFlieId;
           this.Title=dy.Title;
           this.Address=dy.Address;
           this.Gender=dy.Gender;
           this.DateBirth=dy.DateBirth;
           this.Summary=dy.Summary;
           this.Version=dy.Version;
        } 

        #region 定义属性

     
         /// <summary>
        /// 用户ID
        /// </summary>
        private String _UserId = "";
      
        /// <summary>
        /// 用户ID
        /// </summary>
        public String UserId
        {
            get 
            {
              return   (this._UserId); 
            }

            set 
            {
                    _UserId= value;  
            }
        }
       
     
         /// <summary>
        /// 部门
        /// </summary>
        private String _DepartmentId = "";
      
        /// <summary>
        /// 部门
        /// </summary>
        public String DepartmentId
        {
            get 
            {
              return   (this._DepartmentId); 
            }

            set 
            {
                    _DepartmentId= value;  
            }
        }
       
     
         /// <summary>
        /// 姓名
        /// </summary>
        private String _Name = "";
      
        /// <summary>
        /// 姓名
        /// </summary>
        public String Name
        {
            get 
            {
              return   (this._Name); 
            }

            set 
            {
                    _Name= value;  
            }
        }
       
     
         /// <summary>
        /// 邮箱
        /// </summary>
        private String _Email = "";
      
        /// <summary>
        /// 邮箱
        /// </summary>
        public String Email
        {
            get 
            {
              return   (this._Email); 
            }

            set 
            {
                    _Email= value;  
            }
        }
       
     
         /// <summary>
        /// 头像
        /// </summary>
        private String _HeadFlieId = "";
      
        /// <summary>
        /// 头像
        /// </summary>
        public String HeadFlieId
        {
            get 
            {
              return   (this._HeadFlieId); 
            }

            set 
            {
                    _HeadFlieId= value;  
            }
        }
       
     
         /// <summary>
        /// 头衔
        /// </summary>
        private String _Title = "";
      
        /// <summary>
        /// 头衔
        /// </summary>
        public String Title
        {
            get 
            {
              return   (this._Title); 
            }

            set 
            {
                    _Title= value;  
            }
        }
       
     
         /// <summary>
        /// 地址
        /// </summary>
        private String _Address = "";
      
        /// <summary>
        /// 地址
        /// </summary>
        public String Address
        {
            get 
            {
              return   (this._Address); 
            }

            set 
            {
                    _Address= value;  
            }
        }
       
     
         /// <summary>
        /// 性别
        /// </summary>
        private int _Gender =-1;
      
        /// <summary>
        /// 性别
        /// </summary>
        public yq.Enums.UserInfo.Gender Gender
        {
            get 
            {
              return   (yq.Enums.UserInfo.Gender)this._Gender;  
            }

            set 
            {
                    _Gender= value.GetHashCode(); 
            }
        }
       
     
         /// <summary>
        /// 出生日期
        /// </summary>
        private DateTime _DateBirth =DateTime.MinValue;
      
        /// <summary>
        /// 出生日期
        /// </summary>
        public DateTime DateBirth
        {
            get 
            {
              return   (this._DateBirth); 
            }

            set 
            {
                    _DateBirth= value;  
            }
        }
       
     
         /// <summary>
        /// 简介
        /// </summary>
        private String _Summary = "";
      
        /// <summary>
        /// 简介
        /// </summary>
        public String Summary
        {
            get 
            {
              return   (this._Summary); 
            }

            set 
            {
                    _Summary= value;  
            }
        }
       
     
       

      #endregion 定义属性 

          protected internal override void SetValue(UserInfo info, DataRow row) 
          { 
               if (row == null) 
               { 
                 info.IsLoad = false; 
               }
               else 
               { 
                  info.IsLoad = true; 
                  
                  if(row["UserId"]!= DBNull.Value)
                  {
                  info.UserId=row["UserId"].ToString();
                 }
                 
                  
                  if(row["DepartmentId"]!= DBNull.Value)
                  {
                  info.DepartmentId=row["DepartmentId"].ToString();
                 }
                 
                  
                  if(row["Name"]!= DBNull.Value)
                  {
                  info.Name=row["Name"].ToString();
                 }
                 
                  
                  if(row["Email"]!= DBNull.Value)
                  {
                  info.Email=row["Email"].ToString();
                 }
                 
                  
                  if(row["HeadFlieId"]!= DBNull.Value)
                  {
                  info.HeadFlieId=row["HeadFlieId"].ToString();
                 }
                 
                  
                  if(row["Title"]!= DBNull.Value)
                  {
                  info.Title=row["Title"].ToString();
                 }
                 
                  
                  if(row["Address"]!= DBNull.Value)
                  {
                  info.Address=row["Address"].ToString();
                 }
                 
                  
                  if(row["Gender"]!= DBNull.Value)
                  {
                  info.Gender=  (yq.Enums.UserInfo.Gender)(row["Gender"]) ;
                 }
                 
                  
                  if(row["DateBirth"]!= DBNull.Value)
                  {
                  info.DateBirth=Convert.ToDateTime(row["DateBirth"]);
                 }
                 
                  
                  if(row["Summary"]!= DBNull.Value)
                  {
                  info.Summary=row["Summary"].ToString();
                 }
                 
                  
                  if(row["Version"]!= DBNull.Value)
                  {
                  info.Version=row["Version"].ToString();
                 }
                 
               } 

          } 

        protected internal override void GetDbParameters(DbCommand comm, UserInfo info, DbHelper cn) 
        { 
             
                cn.AddInParameter(comm, "@UserId", DbType.String,ParameterTool.GetObj( info._UserId )); 
            
             
                cn.AddInParameter(comm, "@DepartmentId", DbType.String,ParameterTool.GetObj( info._DepartmentId )); 
            
             
                cn.AddInParameter(comm, "@Name", DbType.String,ParameterTool.GetObj( info._Name )); 
            
             
                cn.AddInParameter(comm, "@Email", DbType.String,ParameterTool.GetObj( info._Email )); 
            
             
                cn.AddInParameter(comm, "@HeadFlieId", DbType.String,ParameterTool.GetObj( info._HeadFlieId )); 
            
             
                cn.AddInParameter(comm, "@Title", DbType.String,ParameterTool.GetObj( info._Title )); 
            
             
                cn.AddInParameter(comm, "@Address", DbType.String,ParameterTool.GetObj( info._Address )); 
            
             
                cn.AddInParameter(comm, "@Gender", DbType.Int32,ParameterTool.GetObj( info._Gender )); 
            
             
                cn.AddInParameter(comm, "@DateBirth", DbType.DateTime,ParameterTool.GetObj( info._DateBirth )); 
            
             
                cn.AddInParameter(comm, "@Summary", DbType.String,ParameterTool.GetObj( info._Summary )); 
            
                
                cn.AddInParameter(comm,"@Version", DbType.String, Guid.NewGuid().ToString());
              

                cn.AddInParameter(comm,"@_versionOdl", DbType.String, info._Version); 
                 
        } 

    } 
} 